package yace;

/**
 * 断点续传500个线程压测
 * Created by yangluhua on 2016/9/23 0023.
 */
public class YaCeMain {
    public static void main(String[] args) {
        //将主线程main的优先级降低（作用是为了让main线程在其它线程全部执行完毕后再打印结束时间）
        Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
        long startTime = System.currentTimeMillis();
        YaCeThread testRangThread = null;
        for(int i = 1;i<=1;i++){
            testRangThread = new YaCeThread(i);
            //将测试线程的优先级提高（作用是为了让main线程在其它线程全部执行完毕后再打印结束时间）
            testRangThread.setPriority(Thread.MAX_PRIORITY);
            testRangThread.start();
        }
        //让主线程main睡眠2s防止isAlive判断不准
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        while(testRangThread.isAlive()){}
        long endTime = System.currentTimeMillis();
        long span = (endTime - startTime)/1000;
        //打印耗时，上面等待了2s,所以这边将2s减掉
        System.out.println("共花费时间:"+(span-2)+"秒");
    }
}
